package global

import (
	"log"

	"github.com/prometheus/client_golang/prometheus"
	"github.com/spf13/viper"
	"gorm.io/gorm"
)

var (
	GVA_VP         *viper.Viper
	GVA_MYSQL      *gorm.DB
	GVA_CONFIG     *Configure
	GVA_ALERTLOAD  *prometheus.GaugeVec
	GVA_ALERTLOAD2 *prometheus.GaugeVec
)

func Viper() *viper.Viper {
	v := viper.New()

	v.SetConfigType("yaml")
	v.SetConfigFile("configure.yaml")
	err := v.ReadInConfig()
	if err != nil {
		log.Fatalln("读取不到配置文件")
	}
	if err := v.Unmarshal(&GVA_CONFIG); err != nil {
		log.Fatalln("读取配置文件出错")
	}
	return v
}
